package com.wzu.rjgc_ks.controller;

import com.wzu.rjgc_ks.dao.StuSaveJobMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;
import java.util.HashMap;
import java.util.Map;

@Controller
public class SaveJobAction {

    @Autowired
    StuSaveJobMapper stuSaveJobMapper;

    @ResponseBody
    @RequestMapping(value="/stuSaveJobAction",method = RequestMethod.GET)
    public Map<String,Object> stuSave_Job(@RequestParam("userId") String userId, @RequestParam("jobId") String jobId, HttpServletRequest request){
        //int save_flag = 0;
        Map<String,Object> map = new HashMap<>();
        if(request.getSession().getAttribute("users") != null){
            int user_Id = Integer.parseInt(userId);
            int job_id = Integer.parseInt(jobId);
            stuSaveJobMapper.stuSaveJobMethod(user_Id,job_id);
            map.put("save_flag",1);
            //save_flag = 1;
        }
        else {
            map.put("save_flag",0);
        }
        return map;
    }
}
